from ronglian_sms_sdk import SmsSDK
import json
class CPP:
    def __init__(self,accId = '8aaf07086e0115bb016e873e16fe4da6',
                 accToken = '0f59d259bae548a390fe1607d38a6f23',
                 appId = '2c94811c855ce7250185a0e328380749'):
        print("=== CPP.__init__()===")
        self.sdk = SmsSDK(accId, accToken, appId)

    def send_message(self,tid = '1',mobile = '15033889441',datas = ('4567', '5')):
        # 【云通讯】您的验证码是{1}，请于{2}分钟内正确输入
        json_str = self.sdk.sendMessage(tid, mobile, datas)
        print("json_str=",json_str,",type=",type(json_str))
        python_dict = json.loads(json_str)
        status_code=python_dict.get("statusCode")
        # status_code=="112310":用户发送短信的手机号码没有在容联云服务器后端进行登记时返回的状态码
        if status_code=="000000" or status_code=="112310":
            return 0
        else:
            return -1


if __name__ == '__main__':
    cpp = CPP()
    result = cpp.send_message(mobile="15033889442")
    print("result=",result)